﻿using Dapper.IService;
using Dapper.Model;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;

namespace Dapper.Service
{
    public class DapperService : BaseService<User,Int32>, IDapperService
    {
        //private IConfiguration _configuration;
        public DapperService(IConfiguration configuration)
        {
            _config = configuration;
            //_config.GetSection("DbOption").Value
            _dbConnection = DapperFactory.CreateConnection(_config.GetSection("DbOption").GetSection("DbType").Value, _config.GetSection("DbOption").GetSection("ConnectionString").Value);
        }

        //public DapperService(IOptionsSnapshot<DbOption> options)
        //{
        //    _dbOption = options.Get("test");
        //    _dbConnection = DapperFactory.CreateConnection(_dbOption.DbType, _dbOption.ConnectionString);
        //}
        public int Delete(int id)
        {
            throw new NotImplementedException();
        }

        public int Delete(User entity)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteAsync(int id)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteAsync(User entity)
        {
            //List<Dapper.Model.User> ss = new List<User>();
            throw new NotImplementedException();
        }

        public int DeleteList(object whereConditions, IDbTransaction transaction = null, int? commandTimeout = null)
        {
            throw new NotImplementedException();
        }

        public int DeleteList(string conditions, object parameters = null, IDbTransaction transaction = null, int? commandTimeout = null)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteListAsync(object whereConditions, IDbTransaction transaction = null, int? commandTimeout = null)
        {
            throw new NotImplementedException();
        }

        public Task<int> DeleteListAsync(string conditions, object parameters = null, IDbTransaction transaction = null, int? commandTimeout = null)
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            //throw new NotImplementedException();
            base.Dispose();
        }

        public User Get(int id)
        {
            throw new NotImplementedException();
        }

        public Task<User> GetAsync(int id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<User> GetList()
        {
            //throw new NotImplementedException();
            return _dbConnection.Query<User>("select * from User");
        }

        public IEnumerable<User> GetList(object whereConditions)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<User> GetList(string conditions, object parameters = null)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<User>> GetListAsync()
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<User>> GetListAsync(object whereConditions)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<User>> GetListAsync(string conditions, object parameters = null)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<User> GetListPaged(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<User>> GetListPagedAsync(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null)
        {
            throw new NotImplementedException();
        }

        public int? Insert(User entity)
        {
            throw new NotImplementedException();
        }

        public Task<int?> InsertAsync(User entity)
        {
            throw new NotImplementedException();
        }

        public int RecordCount(string conditions = "", object parameters = null)
        {
            throw new NotImplementedException();
        }

        public Task<int> RecordCountAsync(string conditions = "", object parameters = null)
        {
            throw new NotImplementedException();
        }

        public int Update(User entity)
        {
            throw new NotImplementedException();
        }

        public Task<int> UpdateAsync(User entity)
        {
            throw new NotImplementedException();
        }
    }
}
